<html>
<head><meta charset="utf-8"><title>Where does `sess.crate_name` get set? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20does.20.60sess.2Ecrate_name.60.20get.20set.3F.html">Where does `sess.crate_name` get set?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="218377187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20does%20%60sess.crate_name%60%20get%20set%3F/near/218377187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20does.20.60sess.2Ecrate_name.60.20get.20set.3F.html#218377187">(Dec 01 2020 at 03:34)</a>:</h4>
<p>Somehow, <code>sess.crate_name</code> is never getting set for rustdoc, which means it generates <code>self-profile</code> data that starts with <code>unknown-crate</code> instead of the crate name. I tried adding it and it turns out to be way more complicated than expected - <code>rustc_session::find_crate_name</code> seems to be about right, but it doesn't set any data on <code>sess</code>. Is there a way I'm supposed to do this or is just setting <code>sess.opts.crate_name = find_crate_name()</code> the right way?</p>



<a name="218377734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20does%20%60sess.crate_name%60%20get%20set%3F/near/218377734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20does.20.60sess.2Ecrate_name.60.20get.20set.3F.html#218377734">(Dec 01 2020 at 03:44)</a>:</h4>
<p><span aria-label="face palm" class="emoji emoji-1f926" role="img" title="face palm">:face_palm:</span> rustdoc wasn't setting crate_name for <code>config::Options</code> <a href="https://github.com/rust-lang/rust/blob/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/src/librustdoc/core.rs#L359">https://github.com/rust-lang/rust/blob/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/src/librustdoc/core.rs#L359</a></p>



<a name="218378038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20does%20%60sess.crate_name%60%20get%20set%3F/near/218378038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20does.20.60sess.2Ecrate_name.60.20get.20set.3F.html#218378038">(Dec 01 2020 at 03:51)</a>:</h4>
<p>that did <em>not</em> help</p>



<a name="218378147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20does%20%60sess.crate_name%60%20get%20set%3F/near/218378147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20does.20.60sess.2Ecrate_name.60.20get.20set.3F.html#218378147">(Dec 01 2020 at 03:53)</a>:</h4>
<p>oh because I wasn't passing --crate-name lol</p>



<a name="218378150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20does%20%60sess.crate_name%60%20get%20set%3F/near/218378150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20does.20.60sess.2Ecrate_name.60.20get.20set.3F.html#218378150">(Dec 01 2020 at 03:53)</a>:</h4>
<p>ok I think it should work now</p>



<a name="218378158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20does%20%60sess.crate_name%60%20get%20set%3F/near/218378158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20does.20.60sess.2Ecrate_name.60.20get.20set.3F.html#218378158">(Dec 01 2020 at 03:53)</a>:</h4>
<p>... why do both <code>config::Options</code> and <code>interface::Config</code> have a <code>crate_name</code> field?</p>



<a name="218378930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20does%20%60sess.crate_name%60%20get%20set%3F/near/218378930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20does.20.60sess.2Ecrate_name.60.20get.20set.3F.html#218378930">(Dec 01 2020 at 04:08)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/79586">https://github.com/rust-lang/rust/pull/79586</a></p>



<a name="218468985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20does%20%60sess.crate_name%60%20get%20set%3F/near/218468985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20does.20.60sess.2Ecrate_name.60.20get.20set.3F.html#218468985">(Dec 01 2020 at 19:24)</a>:</h4>
<p>How most Joshua Nelson PRs go: first, ask "why is this thing designed in a weird way"; then, open a PR to make it better <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="218469057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20does%20%60sess.crate_name%60%20get%20set%3F/near/218469057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20does.20.60sess.2Ecrate_name.60.20get.20set.3F.html#218469057">(Dec 01 2020 at 19:24)</a>:</h4>
<p>see, I'm more cynical: "If I don't fix it, it won't get fixed"</p>



<a name="218469119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20does%20%60sess.crate_name%60%20get%20set%3F/near/218469119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20does.20.60sess.2Ecrate_name.60.20get.20set.3F.html#218469119">(Dec 01 2020 at 19:25)</a>:</h4>
<p>Or you can view it in a more positive way: "If I fix it now, it will be better sooner" :)</p>



<a name="218469213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20does%20%60sess.crate_name%60%20get%20set%3F/near/218469213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20does.20.60sess.2Ecrate_name.60.20get.20set.3F.html#218469213">(Dec 01 2020 at 19:26)</a>:</h4>
<p>that too <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="218481434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20does%20%60sess.crate_name%60%20get%20set%3F/near/218481434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20does.20.60sess.2Ecrate_name.60.20get.20set.3F.html#218481434">(Dec 01 2020 at 21:04)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/Where.20does.20.60sess.2Ecrate_name.60.20get.20set.3F/near/218469057">said</a>:</p>
<blockquote>
<p>see, I'm more cynical: "If I don't fix it, it won't get fixed"</p>
</blockquote>
<p>I've actually seen some things from my task queue fixed by others, but that takes years!</p>



<a name="218482156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20does%20%60sess.crate_name%60%20get%20set%3F/near/218482156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20does.20.60sess.2Ecrate_name.60.20get.20set.3F.html#218482156">(Dec 01 2020 at 21:10)</a>:</h4>
<p>in this case, there's also the fact that writing it up into an issue probably would have been more work than just fixing it</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>